<template>
    <div>

 
        {{ fileList }}
        <el-upload  v-model:file-list="fileList" class="upload-demo" :action="BASE_URL + '/upload/add'" :headers="headers"
           list-type="picture">
            <el-button type="primary">Click to upload</el-button>
            <template #tip>
                <div class="el-upload__tip">
                    jpg/png files with a size less than 500kb
                </div>
            </template>
        </el-upload>

        <button @click="submit">提交</button>
    </div>
</template>
<script setup lang='ts'>
import { UploadFile, UploadFiles, UploadProps, UploadUserFile } from 'element-plus';
import { ref, reactive } from 'vue';
 

const BASE_URL = import.meta.env.VITE_BASE_URL;
const IMG_URL = import.meta.env.VITE_IMG_URL;

const headers = reactive({
    Authorization: sessionStorage.getItem('token'),
});

 

const fileList = ref<UploadUserFile[]>([])

const ruleForm = reactive<any>({});

 

const getData = () => {
    //调接口
    const data = {
        "id": 634,
        "name": "34535",
        "mobile": null,
        "pass": null,
        "tel": "34535",
        "logo": "2025/10/27/202510270842318079095.jpg",
        "address": "ss",
        "startTime": "08:50",
        "endTime": "12:40",
        "services": "蔬菜水果",
        "username": "234",
        "intro": "<p>sfsss3453535</p>",
        "images": [
            {
                "id": 40832,
                "storeid": 634,
                "url": "2025/10/27/202510270842571684061.png"
            },
            {
                "id": 40831,
                "storeid": 634,
                "url": "2025/10/27/202510270842035431381.jpg"
            }
        ]
    }




    fileList.value = data.images.map(item => ({ name: item.url, url: IMG_URL + item.url, fileName: item.url }));

    Object.assign(ruleForm, data)

}

getData();

const submit=()=>{


   let filenames= fileList.value.map((item:any)=>item?.response?.data ? item.response.data : item.fileName)


   console.log(filenames);
   

}
</script>
<style scoped lang='less'></style>